package com.ruoyi.web.controller.school;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.school.domain.PacCollege;
import com.ruoyi.school.domain.PacCollege;
import com.ruoyi.school.service.PacCollegeService;
import com.ruoyi.school.service.PacCollegeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/school/College")
public class PacCollegeController extends BaseController {
    @Resource
    private PacCollegeService pacCollegeService;

    @GetMapping("/list")
    public TableDataInfo list(PacCollege pacCollege) {
        startPage();
        List<PacCollege> list = pacCollegeService.getList(pacCollege);
        return getDataTable(list);
    }

    @GetMapping("/details")
    public AjaxResult details(PacCollege pacCollege) {
        PacCollege details = pacCollegeService.getDetails(pacCollege);
        return success(details);
    }

    @Log(title = "学院", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody PacCollege pacCollege) {
        boolean add = pacCollegeService.add(pacCollege);
        return success(add);
    }

    @Log(title = "学院", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult update(@RequestBody PacCollege pacCollege) {
        boolean update = pacCollegeService.edit(pacCollege);
        return success(update);
    }

    @Log(title = "学院", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete")
    public AjaxResult delete(PacCollege pacCollege) {
        boolean delete = pacCollegeService.delete(pacCollege);
        return success(delete);
    }

    @ApiOperation("所有学院")
    @GetMapping("/all")
    public AjaxResult all(PacCollege pacCollege) {
        List<PacCollege> list = pacCollegeService.getAllList(pacCollege);
        return success(list);
    }


}
